package com.yunbai.yunbaigrowup.task;

import android.os.AsyncTask;
import android.os.Handler;
import android.os.Message;

import com.alibaba.fastjson.JSON;
import com.yunbai.yunbaigrowup.impl.GetHisInfoImpl;
import com.yunbai.yunbaigrowup.interfacer.GetHisInfoInterface;
import com.yunbai.yunbaigrowup.model.PointInfo;
import com.yunbai.yunbaigrowup.utils.Common;

public class GetHisTask extends AsyncTask<String, Void, String> {

	private Handler mHandler;
	
	public GetHisTask(Handler mHandler){
		this.mHandler = mHandler;
		getHisImpl = new GetHisInfoImpl();
	}
	private GetHisInfoInterface getHisImpl;
	@Override
	protected String doInBackground(String... params) {
		
		String token = (String)params[0];
		String imei = (String)params[1];
		String startTime = (String)params[2];
		String endTime = (String)params[3];
		String jsonString = getHisImpl.getHisInfo(token,imei,startTime,endTime);
		return jsonString;
	}

	@Override
	protected void onPostExecute(String result) {
		PointInfo hisInof = JSON.parseObject(result, PointInfo.class);
		Message msg = new Message();
		msg.what =Common.ASY_HIS_OK;
		msg.obj = hisInof;
		mHandler.sendMessage(msg);
		super.onPostExecute(result);
	}

}
